namespace Paperless.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddMoreTables : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Categories",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        Description = c.String(),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CheckLists",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        LocationId = c.Long(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CheckListTasks",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        Days = c.Int(nullable: false),
                        Compare = c.Int(nullable: false),
                        DateType = c.Int(nullable: false),
                        Priority = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Content = c.String(),
                        DocumentId = c.Long(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Documents", t => t.DocumentId, cascadeDelete: true)
                .Index(t => t.DocumentId);
            
            CreateTable(
                "dbo.Documents",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        Email = c.String(),
                        LocationId = c.Long(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                        CreateBy = c.Long(nullable: false),
                        IsReview = c.Boolean(nullable: false),
                        TransactionId = c.Long(),
                        CategoryId = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Categories", t => t.CategoryId)
                .ForeignKey("dbo.Locations", t => t.LocationId, cascadeDelete: true)
                .ForeignKey("dbo.Transactions", t => t.TransactionId)
                .Index(t => t.LocationId)
                .Index(t => t.TransactionId)
                .Index(t => t.CategoryId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Comments", "DocumentId", "dbo.Documents");
            DropForeignKey("dbo.Documents", "TransactionId", "dbo.Transactions");
            DropForeignKey("dbo.Documents", "LocationId", "dbo.Locations");
            DropForeignKey("dbo.Documents", "CategoryId", "dbo.Categories");
            DropIndex("dbo.Documents", new[] { "CategoryId" });
            DropIndex("dbo.Documents", new[] { "TransactionId" });
            DropIndex("dbo.Documents", new[] { "LocationId" });
            DropIndex("dbo.Comments", new[] { "DocumentId" });
            DropTable("dbo.Documents");
            DropTable("dbo.Comments");
            DropTable("dbo.CheckListTasks");
            DropTable("dbo.CheckLists");
            DropTable("dbo.Categories");
        }
    }
}
